import cv2
import math
import numpy as np
import random

# 读取图片
image_path = "out_img/Img_0.png"
target = cv2.imread(image_path)

temp = target.copy()
# 识别纯黑像素（RGB 约为 (0,0,0)）
black_pixels = np.all(temp == [255, 255, 255], axis=-1)
# 将纯黑像素替换为纯白
temp[black_pixels] = [0, 0, 0]
cv2.imshow("xxxx",temp)
cv2.waitKey()
cv2.destroyAllWindows()